package com.fangshi.device

import android.content.Context
import android.os.Build
import androidx.lifecycle.LifecycleEventObserver

abstract class Scanner : LifecycleEventObserver {
    abstract fun startScan()
}

fun createScanner(context: Context, onScan: suspend (barcodeStr: String) -> Unit): Scanner {
    return if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
        HandheldScanner(context, onScan)
    } else {
        FakeScanner()
    }
}